package com.devilwwj.update.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class SpUtils {
	private static final String spFileName = "ireader";
	

	public static String getString(Context context, String strKey) {
		SharedPreferences setPreferences = context.getSharedPreferences(
				spFileName, Context.MODE_PRIVATE);
		String result = setPreferences.getString(strKey, "");
		return result;
	}

	public static String getString(Context context, String strKey,
								   String strDefault) {
		SharedPreferences setPreferences = context.getSharedPreferences(
				spFileName, Context.MODE_PRIVATE);
		String result = setPreferences.getString(strKey, strDefault);
		return result;
	}

	public static void putString(Context context, String strKey, String strData) {
		SharedPreferences activityPreferences = context.getSharedPreferences(
				spFileName, Context.MODE_PRIVATE);
		SharedPreferences.Editor editor = activityPreferences.edit();
		editor.putString(strKey, strData);
		editor.commit();
	}

	public static Boolean getBoolean(Context context, String strKey) {
		SharedPreferences setPreferences = context.getSharedPreferences(
				spFileName, Context.MODE_PRIVATE);
		Boolean result = setPreferences.getBoolean(strKey, false);
		return result;
	}

	public static Boolean getBoolean(Context context, String strKey,
									 Boolean strDefault) {
		SharedPreferences setPreferences = context.getSharedPreferences(
				spFileName, Context.MODE_PRIVATE);
		Boolean result = setPreferences.getBoolean(strKey, strDefault);
		return result;
	}
	

	public static void putBoolean(Context context, String strKey,
								  Boolean strData) {
		SharedPreferences activityPreferences = context.getSharedPreferences(
				spFileName, Context.MODE_PRIVATE);
		SharedPreferences.Editor editor = activityPreferences.edit();
		editor.putBoolean(strKey, strData);
		editor.commit();
	}

	public static int getInt(Context context, String strKey) {
		SharedPreferences setPreferences = context.getSharedPreferences(
				spFileName, Context.MODE_PRIVATE);
		int result = setPreferences.getInt(strKey, -1);
		return result;
	}

	public static int getInt(Context context, String strKey, int strDefault) {
		SharedPreferences setPreferences = context.getSharedPreferences(
				spFileName, Context.MODE_PRIVATE);
		int result = setPreferences.getInt(strKey, strDefault);
		return result;
	}

	public static void putInt(Context context, String strKey, int strData) {
		SharedPreferences activityPreferences = context.getSharedPreferences(
				spFileName, Context.MODE_PRIVATE);
		SharedPreferences.Editor editor = activityPreferences.edit();
		editor.putInt(strKey, strData);
		editor.commit();
	}

	public static long getLong(Context context, String strKey) {
		SharedPreferences setPreferences = context.getSharedPreferences(
				spFileName, Context.MODE_PRIVATE);
		long result = setPreferences.getLong(strKey, -1);
		return result;
	}

	public static long getLong(Context context, String strKey, long strDefault) {
		SharedPreferences setPreferences = context.getSharedPreferences(
				spFileName, Context.MODE_PRIVATE);
		long result = setPreferences.getLong(strKey, strDefault);
		return result;
	}

	public static void putLong(Context context, String strKey, long strData) {
		SharedPreferences activityPreferences = context.getSharedPreferences(
				spFileName, Context.MODE_PRIVATE);
		SharedPreferences.Editor editor = activityPreferences.edit();
		editor.putLong(strKey, strData);
		editor.commit();
	}
}
